package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 使用块模式读写形式
 */
public class CopyDemo2 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("./壁纸0.4.jpg");
        FileOutputStream fos = new FileOutputStream("./image_cp2.jpg");
        int len;

        byte[] date = new byte[1024*10];//10kb
        long start = System.currentTimeMillis();
        while ((len = fis.read(date))!=-1){
            fos.write(date,0,len);
        }
        long end = System.currentTimeMillis();
        System.out.println("复制完成,耗时：" + (end-start) + "ms");
        fis.close();
        fos.close();

    }
}
